package com.newlink.building.userinfo.mvp

import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.model.bean.*
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_LocalMsgContract
import com.newlink.building.userinfo.mvp.model.Module_UserInfo_LocalMsgModel

/**
 * @Author: Jake
 * @Date: 2023-12-11
 * @Description:
 */
class Module_UserInfo_LocalMsgPresenter : BasePresenter<Module_UserInfo_LocalMsgContract.Model, Module_UserInfo_LocalMsgContract.View>(),
    Module_UserInfo_LocalMsgContract.Presenter {

    override fun createModel(): Module_UserInfo_LocalMsgContract.Model? {
        return Module_UserInfo_LocalMsgModel()
    }

    override fun getMessageList(request: MessageListRequest) {
        mModel?.getMessageList(request)?.ss(mModel, mView) { result ->
            mView?.hideLoading()
            if (result?.data != null) {
                mView?.getMessageListSuccess(result?.data!!.list)
            }
        }
    }

    override fun deleteAllMessageList(request: MessageCleanRequest) {
        mModel?.deleteAllMessageList(request)?.ss(mModel, mView) { result ->
            mView?.hideLoading()
            if (result?.code == 200) {
                mView?.deleteAllMessageListSuccess()
            } else {
                mView?.deleteAllMessageListFail()
            }
        }
    }
}